#ifndef __EVENT_H__00F51F00_9EBA_4bd7_AC78_1819E0CE4D34__
#define __EVENT_H__00F51F00_9EBA_4bd7_AC78_1819E0CE4D34__

#include "delegate.h"

namespace babyfish
{
	template <typename T>
	class event_wrapper
	{
	public:
		event_wrapper(T& delegate_ref) : delegate_ref(delegate_ref)
		{
		}

		void operator += (const T& delegate_to_add)
		{ this->delegate_ref += (delegate_to_add); }

		void operator -= (const T& delegate_to_add)
		{ this->delegate_ref -= (delegate_to_add); }
	private:
		T& delegate_ref;
	};

	class event_args
	{
	public:
		static event_args& empty()
		{
			static event_args empty;
			return empty;
		}
	};

	/*
	 *	template <typename E = babyfish::event_args>
	 *	delegate void event_handler(void* sender, E& e);
	 */
	template <typename E = babyfish::event_args>
	class event_handler : public delegate_base
	{
	private:
		typedef event_handler<E> self_type;
		members_for_delegate_void(event_handler, self_type, (void* sender, E& e), (sender, e))
	};
}

#define declare_event(delegate_type, event_field, delegate_field) \
	babyfish::event_wrapper< delegate_type > event_field() \
	{ return babyfish::event_wrapper< delegate_type >(delegate_field); }

#endif //__EVENT_H__00F51F00_9EBA_4bd7_AC78_1819E0CE4D34__